package com.project.datacenter.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.project.datacenter.dto.ParamDto;
import com.project.datacenter.entity.TobjBusVehicle;
import com.project.datacenter.mapper.TobjBusVehicleMapper;
import com.project.datacenter.service.BusVehicleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BusVehicleServiceImpl implements BusVehicleService {

    @Resource
    private TobjBusVehicleMapper tobjBusVehicleMapper;

    @Override
    @DS("datacenter")
    public List<TobjBusVehicle> getList() {
        return tobjBusVehicleMapper.getList();
    }

    @Override
    @DS("master")
    public List<TobjBusVehicle> getListByDate(ParamDto paramDto) {
        return tobjBusVehicleMapper.selectByDate(paramDto);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    @DS("master")
    public void saveList(List<TobjBusVehicle> list) {
        for (TobjBusVehicle entity : list) {
            tobjBusVehicleMapper.insertSelective(entity);
        }
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    @DS("master")
    public void deleteByDate(ParamDto paramDto) {
        tobjBusVehicleMapper.deleteByDate(paramDto);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    @DS("master")
    public void deleteExpireDate(ParamDto paramDto) {
        tobjBusVehicleMapper.deleteExpireDate(paramDto);
    }

}
